/******************************************************************************************
* Project: Workhorses of Opportunity — Howard and Weinstein
*
* Inputs:
*   - "tfs_cleaned.dta"
*
* Outputs:
*   - coefplot_cost.pdf         // Cost, aid, and financing-related reasons
*   - coefplot_jobs.pdf         // Job, money, training, and future motivation
*   - coefplot_info.pdf         // Networks and information sources
*   - coefplot_acad.pdf         // Academic, learning, and ranking-related reasons
*   - coefplot_loc.pdf          // Location preferences and constraints
*   - coefplot_oth.pdf          // Other personal reasons (e.g., purpose, religion)
*   - coefplot_apps.pdf         // Applications, test scores, and selectivity
*   - coefplot_demog.pdf        // Demographics and family background
******************************************************************************************/

*---------------------------*
* Cost & Financing Regressions
*---------------------------*
use "tfs_cleaned", clear
set scheme s1color 

local vars c_notafffirstv c_notafffirsts c_liveathomev c_liveathomes  c_offeredaidv c_offeredaids c_notaidfirstv c_notaidfirsts c_costv c_costs c_lowtuitv  c_lowtuits f_jobv  f_jobs f_ftjobv  f_ftjobs f_outsidejobv f_outsidejobs finconv  fincons planlivefam planlivefamprefoth a_fam_c a_own_c a_gr_c a_loan_c a_oth_c a_othcoll82_y a_othcoll82_m

keep `vars' home_hasnormalschool homestate year homectyfips studwgt
collapse `vars' [w=studwgt], by(homectyfips homestate home_hasnormalschool)

* Label variables for plotting
cap label var r_jobv "Going to college for job; V. Important"
cap label var r_jobs "Going to college for job; V./S. Important"
cap label var c_notafffirstv "Chose college because could not afford 1st choice; V. Important"
cap label var c_notafffirsts "Chose college because could not afford 1st choice; V./S. Important"
cap label var c_liveathomev "Chose college because wanted to live at home; V. Important"
cap label var c_liveathomes "Chose college because wanted to live at home; V./S. Important"
cap label var c_offeredaidv "Chose college because offered aid; V. Important"
cap label var c_offeredaids "Chose college because offered aid; V./S. Important"
cap label var c_notaidfirstv "Chose college because not offered aid at 1st choice; V. Important"
cap label var c_notaidfirsts "Chose college because not offered aid at 1st choice; V./S. Important"
cap label var c_costv "Chose college because cost; V. Important"
cap label var c_costs "Chose college because cost; V./S. Important"
cap label var c_lowtuitv "Chose college because low tuition; V. Important"
cap label var c_lowtuits "Chose college because low tuition; V./S. Important"
cap label var f_jobv "Likely to have job to pay for college; V. Good"
cap label var f_jobs "Likely to have job to pay for college; V./S. Good"
cap label var f_ftjobv "Likely to have full-time job in college; V. Good"
cap label var f_ftjobs "Likely to have full-time job in college; V./S. Good"
cap label var f_outsidejobv "Likely to have to work outside job in college; V. Good"
cap label var f_outsidejobs "Likely to have to work outside job in college; V./S. Good"
cap label var finconv "Concern about financing college; Major"
cap label var fincons "Concern about financing college; Some/Major"
cap label var planlivefam "Plan on living with family freshman year"
cap label var planlivefamprefoth "Plan on living with family freshman year; prefer elsewhere"
cap label var a_fam_c "Financing college via family and friends"
cap label var a_own_c "Financing college via own savings"
cap label var a_gr_c "Financing college via grants"
cap label var a_loan_c "Financing college via loans"
cap label var a_oth_c "Financing college via other"
cap label var a_othcoll82_y "Aid constrained choice: yes"
cap label var a_othcoll82_m "Aid constrained choice: maybe/yes"

* Regressions and plot
foreach x of local vars {
	reghdfe `x' home_hasnormalschool if home_hasnormalschool~=. , absorb(homestate) cluster(homestate)
	estimates store `x'
}

coefplot `vars', asequation swapnames drop(_cons) xline(0, lpattern(dash) lcolor(gs8)) ///
	legend(off) grid(none) coeflabels(,labsize(small)) ci(95 90) ///
	ciopts(recast(rspike rcap) lcolor(dkgreen dkgreen)) mcolor(dkgreen)

graph export "coefplot_cost.pdf", as(pdf) replace

*---------------------------*
* Better Financial Future
*---------------------------*
use "tfs_cleaned", clear

local vars r_jobv r_jobs r_moneyv r_moneys r_trainingv r_trainings r_nojobv r_nojobs r_nothingbetv r_nothingbets c_goodjobsv c_goodjobss

keep `vars' home_hasnormalschool homestate year homectyfips studwgt
collapse `vars' [w=studwgt], by(homectyfips homestate home_hasnormalschool)


cap label var r_jobv "Going to college for better job; V. Important"
cap label var r_jobs "Going to college for better job; V./S. Important"

cap label var r_moneyv "Going to college to make more money; V. Important"
cap label var r_moneys "Going to college to make more money; V./S. Important"

cap label var r_trainingv "Going to college for training for career; V. Important"
cap label var r_trainings "Going to college for training for career; V./S. Important"

cap label var r_nojobv "Going to college because no job; V. Important"
cap label var r_nojobs "Going to college because no job; V./S. Important"

cap label var r_nothingbetv "Going to college because nothing better; V. Important"
cap label var r_nothingbets "Going to college because nothing better; V./S. Important"

cap label var c_goodjobsv "Chose college because of graduates' jobs; V. Important"
cap label var c_goodjobss "Chose college because of graduates' jobs; V./S. Important"


foreach x of local vars {
	reghdfe `x' home_hasnormalschool if home_hasnormalschool~=. , absorb(homestate) cluster(homestate)
	estimates store `x'
}

coefplot `vars', asequation swapnames drop(_cons) xline(0, lpattern(dash) lcolor(gs8)) ///
	legend(off) grid(none) coeflabels(,labsize(small)) ci(95 90) ///
	ciopts(recast(rspike rcap) lcolor(dkgreen dkgreen)) mcolor(dkgreen)

graph export "coefplot_jobs.pdf", as(pdf) replace

*---------------------------*
* Networks and Information
*---------------------------*
use "tfs_cleaned", clear

local vars r_mentorv r_mentors r_parentsv r_parentss r_friendsgoingv r_friendsgoings ///
	c_collegerepv c_collegereps c_friendsuggv c_friendsuggs c_visitv c_visits c_hscounsv c_hscounss ///
	c_websiteinfv c_websiteinfs c_parentsv c_parentss c_relativesv c_relativess c_teacherv c_teachers ///
	c_prvtcounsv c_prvtcounss c_guidev c_guides c_friendsattv c_friendsatts c_prevstudv c_prevstuds

keep `vars' home_hasnormalschool homestate year homectyfips studwgt
collapse `vars' [w=studwgt], by(homectyfips homestate home_hasnormalschool)


cap label var r_mentorv "Going to college because of a mentor; V. Important"
cap label var r_mentors "Going to college because of a mentor; V./S. Important"

cap label var r_parentsv "Going to college because of parents; V. Important"
cap label var r_parentss "Going to college because of parents; V./S. Important"

cap label var r_friendsgoingv "Going to college because of friends going; V. Important"
cap label var r_friendsgoings "Going to college because of friends going; V./S. Important"

cap label var c_collegerepv "Chose college because of college representative; V. Important"
cap label var c_collegereps "Chose college because of college representative; V./S. Important"

cap label var c_friendsuggv "Chose college because of friend; V. Important"
cap label var c_friendsuggs "Chose college because of friend; V./S. Important"

cap label var c_visitv "Chose college because of visit; V. Important"
cap label var c_visits "Chose college because of visit; V./S. Important"

cap label var c_hscounsv "Chose college because of HS counselor; V. Important"
cap label var c_hscounss "Chose college because of HS counselor; V./S. Important"

cap label var c_websiteinfv "Chose college because of website; V. Important"
cap label var c_websiteinfs "Chose college because of website; V./S. Important"

cap label var c_parentsv "Chose college because of parents; V. Important"
cap label var c_parentss "Chose college because of parents; V./S. Important"

cap label var c_relativesv "Chose college because of relatives; V. Important"
cap label var c_relativess "Chose college because of relatives; V./S. Important"

cap label var c_teacherv "Chose college because of teacher; V. Important"
cap label var c_teachers "Chose college because of teacher; V./S. Important"

cap label var c_prvtcounsv "Chose college because of private counselor; V. Important"
cap label var c_prvtcounss "Chose college because of private counselor; V./S. Important"

cap label var c_guidev "Chose college because of guidebook; V. Important"
cap label var c_guides "Chose college because of guidebook; V./S. Important"

cap label var c_friendsattv "Chose college because friends attending; V. Important"
cap label var c_friendsatts "Chose college because friends attending; V./S. Important"

cap label var c_prevstudv "Chose college because previous student's suggestion; V. Important"
cap label var c_prevstuds "Chose college because previous student's suggestion; V./S. Important"


foreach x of local vars {
	reghdfe `x' home_hasnormalschool if home_hasnormalschool~=. , absorb(homestate) cluster(homestate)
	estimates store `x'
}

coefplot `vars', asequation swapnames drop(_cons) xline(0, lpattern(dash) lcolor(gs8)) ///
	legend(off) grid(none) coeflabels(,labsize(small)) ci(95 90) ///
	ciopts(recast(rspike rcap) lcolor(dkgreen dkgreen)) mcolor(dkgreen)

graph export "coefplot_info.pdf", as(pdf) replace

*---------------------------*
* Learning and Academics
*---------------------------*
use "tfs_cleaned", clear

local vars r_genedv r_geneds r_readingv r_readings r_learnintv r_learnints r_gradschv r_gradschs ///
	r_culturev r_cultures c_rankv c_ranks c_acadreputv c_acadreputs ///
	c_specedv c_speceds c_topgradv c_topgrads c_onlinev c_onlines

keep `vars' home_hasnormalschool homestate year homectyfips studwgt
collapse `vars' [w=studwgt], by(homectyfips homestate home_hasnormalschool)


cap label var r_genedv "Going to college for general Ed.; V. Important"
cap label var r_geneds "Going to college for general Ed.; V./S. Important"

cap label var r_readingv "Going to college for reading skills; V. Important"
cap label var r_readings "Going to college for reading skills; V./S. Important"

cap label var r_learnintv "Going to college to learn interesting things; V. Important"
cap label var r_learnints "Going to college to learn interesting things; V./S. Important"

cap label var r_gradschv "Going to college for grad. sch.; V. Important"
cap label var r_gradschs "Going to college for grad. sch.; V./S. Important"

cap label var r_culturev "Going to college to become cultured; V. Important"
cap label var r_cultures "Going to college to become cultured; V./S. Important"

cap label var c_rankv "Chose college because of rank; V. Important"
cap label var c_ranks "Chose college because of rank; V./S. Important"

cap label var c_acadreputv "Chose college because of academic reputation; V. Important"
cap label var c_acadreputs "Chose college because academic reputation; V./S. Important"

cap label var c_specedv "Chose college because of special ed.; V. Important"
cap label var c_speceds "Chose college because of special ed.; V./S. Important"

cap label var c_topgradv "Chose college because grads' in top grad. sch.; V. Important"
cap label var c_topgrads "Chose college because grads' in top grad. sch.; V./S. Important"

cap label var c_onlinev "Chose college because of online ed.; V. Important"
cap label var c_onlines "Chose college because of online ed.; V./S. Important"

foreach x of local vars {
	reghdfe `x' home_hasnormalschool if home_hasnormalschool~=. , absorb(homestate) cluster(homestate)
	estimates store `x'
}

coefplot `vars', asequation swapnames drop(_cons) xline(0, lpattern(dash) lcolor(gs8)) ///
	legend(off) grid(none) coeflabels(,labsize(small)) ci(95 90) ///
	ciopts(recast(rspike rcap) lcolor(dkgreen dkgreen)) mcolor(dkgreen)

graph export "coefplot_acad.pdf", as(pdf) replace

*---------------------------*
* Location
*---------------------------*
use "tfs_cleaned", clear

local vars r_awayhomev r_awayhomes r_newpeoplev r_newpeoples ///
	c_nearhomev c_nearhomes c_liveathomev c_liveathomes ///
	c_locnoothoptionv c_locnoothoptions

keep `vars' home_hasnormalschool homestate year homectyfips studwgt
collapse `vars' [w=studwgt], by(homectyfips homestate home_hasnormalschool)


cap label var r_awayhomev "Going to college to get away from home; V. Important"
cap label var r_awayhomes "Going to college to get away from home; V./S. Important"

cap label var r_newpeoplev "Going to college to meet new people; V. Important"
cap label var r_newpeoples "Going to college to meet new people; V./S. Important"

// cap label var c_nearhomev "Chose college because it is near home; V. Important"
// cap label var c_nearhomes "Chose college because it is near home; V./S. Important"
//
// cap label var c_liveathomev "Chose college because I can live at home; V. Important"
// cap label var c_liveathomes "Chose college because I can live at home; V./S. Important"

cap label var c_nearhomev "Chose college because wanted to live near home; V. Important"
cap label var c_nearhomes "Chose college because wanted to live near home; V./S. Important"

cap label var c_liveathomev "Chose college because wanted to live at home; V. Important"
cap label var c_liveathomes "Chose college because wanted to live at home; V./S. Important"

cap label var c_locnoothoptionv "Chose college because it is local; No other opt.; V. Important"
cap label var c_locnoothoptions "Chose college because it is local; No other opt.; V./S. Important"



foreach x of local vars {
	reghdfe `x' home_hasnormalschool if home_hasnormalschool~=. , absorb(homestate) cluster(homestate)
	estimates store `x'
}

coefplot `vars', asequation swapnames drop(_cons) xline(0, lpattern(dash) lcolor(gs8)) ///
	legend(off) grid(none) coeflabels(,labsize(small)) ci(95 90) ///
	ciopts(recast(rspike rcap) lcolor(dkgreen dkgreen)) mcolor(dkgreen)

graph export "coefplot_loc.pdf", as(pdf) replace

*---------------------------*
* Other Reasons
*---------------------------*
use "tfs_cleaned", clear

local vars r_provev r_proves r_findpurpv r_findpurps c_sizev c_sizes c_earlyv c_earlys ///
	c_religv c_religs c_socialv c_socials c_racev c_races c_safetyv c_safetys

keep `vars' home_hasnormalschool homestate year homectyfips studwgt
collapse `vars' [w=studwgt], by(homectyfips homestate home_hasnormalschool)


cap label var r_provev "Going to college to prove to others; V. Important"
cap label var r_proves "Going to college to prove to others; V./S. Important"

cap label var r_findpurpv "Going to college to find purpose; V. Important"
cap label var r_findpurps "Going to college to find purpose; V./S. Important"

cap label var c_sizev "Chose college because size; V. Important"
cap label var c_sizes "Chose college because size; V./S. Important"

cap label var c_earlyv "Chose college because applied early; V. Important"
cap label var c_earlys "Chose college because applied early; V./S. Important"

cap label var c_religv "Chose college because religious affil.; V. Important"
cap label var c_religs "Chose college because religious affil.; V./S. Important"

cap label var c_socialv "Chose college because social reput.; V. Important"
cap label var c_socials "Chose college because social reput.; V./S. Important"

cap label var c_racev "Chose college because racial composition; V. Important"
cap label var c_races "Chose college because racial composition; V./S. Important"

cap label var c_safetyv "Chose college because campus safety; V. Important"
cap label var c_safetys "Chose college because campus safety; V./S. Important"



foreach x of local vars {
	reghdfe `x' home_hasnormalschool if home_hasnormalschool~=. , absorb(homestate) cluster(homestate)
	estimates store `x'
}

coefplot `vars', asequation swapnames drop(_cons) xline(0, lpattern(dash) lcolor(gs8)) ///
	legend(off) grid(none) coeflabels(,labsize(small)) ci(95 90) ///
	ciopts(recast(rspike rcap) lcolor(dkgreen dkgreen)) mcolor(dkgreen)

graph export "coefplot_oth.pdf", as(pdf) replace

*---------------------------*
* College Applications & Scores
*---------------------------*
use "tfs_cleaned", clear
gen sattothun = sattot/1000

local vars c_onlyacceptv c_onlyaccepts numapply numapplyone rate01 actcompUSE sattothun f_transfv f_transfs firstchoice

keep `vars' home_hasnormalschool homestate year homectyfips studwgt
collapse `vars' [w=studwgt], by(homectyfips homestate home_hasnormalschool)



cap label var c_onlyacceptv "Chose college because only acceptance; V. Important"
cap label var c_onlyaccepts "Chose college because only acceptance; V./S. Important"

cap label var f_transfv "Likely to Transfer; V. Good"
cap label var f_transfs "Likely to Transfer; V./S. Good"

cap label var numapply "Number of college applications (10s)"


cap label var numapplyone "Applied to one college"

cap label var actcompUSE "ACT composite score (10s)"



cap label var sattot "SAT score"
cap label var sattothun "SAT score (1000s)"

cap label var rate01 "Self-rating: academic ability"

cap label var firstchoice "This college was first choice"



replace numapply = numapply / 10
replace actcompUSE = actcompUSE / 10

foreach x of local vars {
	reghdfe `x' home_hasnormalschool if home_hasnormalschool~=. , absorb(homestate) cluster(homestate)
	estimates store `x'
}

coefplot `vars', asequation swapnames drop(_cons) xline(0, lpattern(dash) lcolor(gs8)) ///
	legend(off) grid(none) coeflabels(,labsize(small)) ci(95 90) ///
	ciopts(recast(rspike rcap) lcolor(dkgreen dkgreen)) mcolor(dkgreen)

graph export "coefplot_apps.pdf", as(pdf) replace

*---------------------------*
* Background Characteristics
*---------------------------*
use "tfs_cleaned", clear

local vars fatheduc2 fatheduc3 fatheduc5 fatheduc6 fatheduc8 motheduc2 motheduc3 motheduc5 motheduc6 motheduc8 white male ageUSE lninc_midpoint
keep `vars' home_hasnormalschool homestate year homectyfips studwgt
collapse `vars' [w=studwgt], by(homectyfips homestate home_hasnormalschool)



cap label var fatheduc2 "Dad educ: Some HS"
cap label var fatheduc3 "Dad educ: HS"
cap label var fatheduc5 "Dad educ: Some college"
cap label var fatheduc6 "Dad educ: College"
cap label var fatheduc8 "Dad educ: Grad. sch"

cap label var motheduc2 "Mom educ: Some HS"
cap label var motheduc3 "Mom educ: HS"
cap label var motheduc5 "Mom educ: Some college"
cap label var motheduc6 "Mom educ: College"
cap label var motheduc8 "Mom educ: Grad. sch"

cap label var white "Race: White"
cap label var male "Male"
cap label var ageUSE "Age (10s)"
cap label var lninc_midpoint "Log parent income"

replace ageUSE = ageUSE / 10

foreach x of local vars {
	reghdfe `x' home_hasnormalschool if home_hasnormalschool~=. , absorb(homestate) cluster(homestate)
	estimates store `x'
}

coefplot `vars', asequation swapnames drop(_cons) xline(0, lpattern(dash) lcolor(gs8)) ///
	legend(off) grid(none) coeflabels(,labsize(small)) ci(95 90) ///
	ciopts(recast(rspike rcap) lcolor(dkgreen dkgreen)) mcolor(dkgreen)

graph export "coefplot_demog.pdf", replace
